package com.yidian.dao;

import com.yidian.pojo.goods.Spec;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

/**
 * @author whb
 * @create 2021-05-17 20:51
 * @decription 商品规格通用Mapper
 */
public interface SpecMapper extends Mapper<Spec> {
    /**
     * 根据商品分类名称，查询商品规格列表
     * @param categoryName
     * @return
     */
    @Select("SELECT name,options FROM tb_spec WHERE template_id IN(" +
            "SELECT DISTINCT template_id FROM tb_category WHERE NAME=#{categoryName}" +
            ") ORDER BY seq")
    public List<Map> findSpecListByCategoryName(@Param("categoryName") String categoryName);
}
